<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="keywords" content="广东国防教育学会">
    <meta name="description" content="广东国防教育学会">
    <title>广东国防教育学会</title>
    <link rel="shortcut icon" href="/Public/Admin/img/favicon.ico">
    <link href="/Public/Admin/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="/Public/Admin/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="/Public/Admin/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" href="/Public/Admin/bootstrap_validator-0.4.5/dist/css/bootstrapValidator.css"/>
    <link href="/Public/Admin/css/animate.min.css" rel="stylesheet">
    <link href="/Public/Admin/plugins/iCheck/all.css" rel="stylesheet">
    <style>
		/* *{
			color:#000;
		} */
		.btn{
		 	 padding: 5px 8px;
		 	 /* border-radius: 0px; */
			font-size:12px;
			margin-bottom:0px;
		}
		.table{
	    	width: 100%;
		}
		.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{
			padding:0px 5px;
			/*text-align: center;*/
			vertical-align: middle!important;
		}
		.form-control{
			font-size: 12px;
		}
		#file-pretty button{
			padding: 7.5px 13px;
		}
		p{
	   		 margin: 0 0;
		}
		.pagination{
			margin:0px 0px;
		}
		.select_width{
			width:100px;
		}
		.select_no_border{
			border-right: none;
		}
	</style>
</head>
<style>
    .pagination a {
        background-color: #f4f4f4;
        z-index: 2;
        border: 1px solid #000;
        border-color: rgb(221, 221, 221);
        padding: 4px 10px;
        margin: 0px 3px;
        border-radius: 10%;
    }

    .select_no_border{
        border-right: none;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>答题信息列表</h5>
                    <div class="ibox-tools" style="margin-top: -6px;">
                        <a href="/Admin/<?php echo (CONTROLLER_NAME); ?>/<?php echo (ACTION_NAME); ?>" class="btn btn-primary"><i class="fa fa-refresh"></i> 刷新</a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <!--<div class="col-sm-3" style="width: 20%;">
                            &lt;!&ndash;<a href="/Admin/Answer/addQuestion" class="btn btn-primary">
                                <span class="fa fa-plus"></span>
                                添加题库
                            </a>&ndash;&gt;
                        </div>-->
                        <form class="form-inline" action="/Admin/Answer/answerInfoList" method="get">
                            <div class="col-sm-12">
                                <div class="input-group col-sm-4  pull-right" style="width: 300px;">
                                    <input type="text" name="username" placeholder="请输入用户名" value="<?php echo I('username');?>" class="input-sm form-control">
                                    <span class="input-group-btn">
                                        <button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
                                    </span>
                                </div>

                                <div class="input-group col-sm-2 pull-right">
                                    <input type="text" name="school" value="<?php echo I('school');?>" placeholder="请输入学校名称" class="input-sm form-control select_no_border">
                                </div>

                                <div class="input-group col-sm-2 pull-right">
                                    <select name="area" id="area" class="input-sm form-control select_no_border">
                                        <option value="0">请选择区/县</option>
                                        <!--处理第一次只选市搜索后再点区的情况-->
                                        <?php if(is_array($areadata)): $i = 0; $__LIST__ = $areadata;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option label="<?php echo ($vo["name"]); ?>"  value="<?php echo ($vo["name"]); ?>" ><?php echo ($vo["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                                    </select>
                                </div>

                                <div class="input-group col-sm-2 pull-right">
                                    <select name="city" id="city" onchange="loadRegion('city',3,'area','<?php echo U('Answer/getRegion');?>');" class="input-sm form-control select_no_border">
                                        <option value="0">请选择城市</option>
                                        <?php if(is_array($province)): $i = 0; $__LIST__ = $province;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option <?php if($vo["id"] == $city): ?>selected<?php endif; ?> value="<?php echo ($vo["name"]); ?>_<?php echo ($vo["id"]); ?>" ><?php echo ($vo["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                                    </select>
                                </div>
                            </div>
                        </form>
                    </div>

                    <br/>
                    <div class="table-responsive">
                        <form id="allDelForm" action="/Admin/Answer/deleteAllInfo" method="post">
                            <table class="table table-bordered table-hover"
                                   id="categoryTable">
                                <thead>
                                <tr class="active">
                                    <th width="50px"><input onclick="choosebox(this)" type="checkbox"/></th>
                                    <th width="100px" height="40">ID</th>
                                    <th>用户名</th>
                                    <th>地区</th>
                                    <th>学校</th>
                                    <th>得分</th>
                                    <th>答题用时</th>
                                    <!--<th>奖励积分</th>-->
                                    <th>答题时间</th>
                                    <th width="100px">操作</th>
                                </tr>
                                </thead>

                                <tbody>
                                <?php if(is_array($data)): $k = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($k % 2 );++$k;?><tr>
                                    <td><input type="checkbox" name="id[]" value="<?php echo ($vo['id']); ?>"/></td>
                                    <!--<td><?php echo ($k + ($p - 1) * $perCount); ?></td>-->
                                    <td><?php echo ($vo['id']); ?></td>
                                    <td><?php echo ($vo['nickname']); ?></td>
                                    <td><?php echo ($vo['city']); echo ($vo['area']); ?></td>
                                    <td><?php echo ($vo['school']); ?></td>
                                    <td><?php echo ($vo['score']); ?></td>
                                    <td><?php echo ($vo['total_time']); ?>秒</td>
                                    <!--<td><?php echo ($vo['jifen']); ?></td>-->
                                    <td><?php echo (date("Y-m-d H:i:s",$vo['add_time'])); ?></td>
                                    <td class="center">
                                        <div class="dropdown">
                                            <button class="btn btn-primary dropdown-toggle"
                                                    type="button" id="dropdownMenu1" data-toggle="dropdown"
                                                    aria-haspopup="true" aria-expanded="true">
                                                操作
                                                <span class="caret"></span>
                                            </button>
                                            <ul style="min-width: 90px;" class="dropdown-menu" aria-labelledby="dropdownMenu1">
                                                <li>
                                                    <a role="button" class="btn btn-primary"
                                                       style="margin-bottom: 0px;"
                                                       href="/Admin/Answer/answerInfoEdit?id=<?php echo ($vo['id']); ?>">
                                                        <span class="fa fa-edit"></span>
                                                        修改
                                                    </a>
                                                </li>
                                                <li>
                                                    <a role="button" class="btn btn-danger"
                                                       style="margin-bottom: 0px;"
                                                       onclick="deleteQuestion(this,<?php echo ($vo['id']); ?>)">
                                                        <span class="fa fa-trash-o"></span>
                                                        删除
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                                </tbody>
                            </table>

                        </form>
                        <div style="padding-left:0px;" class="col-sm-3 text-left">
                            <button id="allDel" class="btn btn-danger">删除</button>
                        </div>
                        <div class="col-sm-12 text-center">
                            <nav aria-label="Page navigation">
                                <ul class="pagination">
                                    <?php echo ($page); ?>
                                </ul>
                            </nav>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="/Public/Admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/Public/Admin/js/bootstrap.min.js?v=3.3.6"></script>
<!-- <script src="/Public/Admin/js/content.min.js?v=1.0.0"></script> -->
<script type="text/javascript" src="/Public/Admin/bootstrap_validator-0.4.5/dist/js/bootstrapValidator.js"></script>
<script src="/Public/Admin/plugins/layer/layer.js"></script>
<script src="/Public/Admin/plugins/iCheck/icheck.min.js"></script>

<script>
//设置checkbox按钮
$('.i-check').iCheck({
	checkboxClass : "icheckbox_square-green",
	radioClass : "iradio_square-green",
});
</script>

</body>
</html>
<script>
    var area = "<?php echo ($area); ?>";
    $(document).ready(function () {
        //选中区状态
        if(Number(area) != 0)
        {
            $("#area option").each(function(){
                if($(this).attr('label') == area){
                    $(this).attr("selected",true);
                }
            });
        }
    });
</script>

<script>
    function choosebox(o) {
        var vt = $(o).is(':checked');
        if (vt) {
            $('input[type=checkbox]').prop('checked', vt);
        } else {
            $('input[type=checkbox]').removeAttr('checked');
        }
    }
</script>

<script>
    //删除
    function deleteQuestion(obj, id) {
        layer.confirm('确定要删除数据吗', {btn: ['确认', '取消'], icon: 3, closeBtn: 2}, function (index) {
            $.ajax({
                url: '/Admin/Answer/answerInfoDel',
                data: {'id': id},
                type: 'get',
                dataType: 'json',
                async: false,   //取消同步，执行完之后再往下执行
                success: function (data) {
                    if (data.status == 1) {
                        layer.msg('' + data.message + '', {icon: 2, time: 1000});
                        $(obj).parent('li').parent('ul').parent('div').parent('td').parent('tr').remove();
                    } else if (data.status == 2) {
                        layer.msg('' + data.message + '', {icon: 1, time: 1000});
                    }
                }
            });
        });
    }

   $("#allDel").click(function () {
       layer.confirm('确定要删除数据吗', {btn: ['确认', '取消'], icon: 3, closeBtn: 2}, function (index) {
           $("#allDelForm").submit();
       });
   });

    function loadRegion(sel,type_id,selName,url){
        //alert(123)
       var p_id = jQuery("#"+sel).val();
        var idarray = p_id .split("_");

        jQuery("#"+selName+" option").each(function(){
            jQuery(this).remove();
        });

        if (type_id ==3)
            jQuery("<option value=0>请选择区/县</option>").appendTo(jQuery("#"+selName));

        //没选择
        if(jQuery("#"+sel).val() ==0){
            return;
        }
        //return false;
        jQuery.getJSON(url,{pid:idarray[1],type:type_id},
            function(data){
                if(data){
                    jQuery.each(data,function(i,item){
                        jQuery("<option  value="+item.name+">"+item.name+"</option>").appendTo(jQuery("#"+selName));
                    });
                }else{
                    jQuery("<option value='0'>请选择</option>").appendTo(jQuery("#"+selName));
                }
            }
        );
    }
</script>
</body>
</html>